libxl: Hold the atfork lock while closing carefd
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 24 Feb 2014 14:19:14 +0000 (14:19 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 13 Mar 2014 12:50:07 +0000 (12:50 +0000)
commit2a0c3a62ea4ad6c6bcbf80122b070f3ff3fe7dae
tree06fbba61fe73244eb85eaf82498b0134addd3884
parent5f979614eae087042f0283fa03186e97e5e04f70
libxl: Hold the atfork lock while closing carefd

This avoids the process being forked while a carefd is recorded in the
list but the actual fd has been closed.  If that happened, a
subsequent libxl_postfork_child_noexec would attempt to close the fd
again.  If we are lucky that results in a harmless warning; but if we
are unlucky the fd number has been reused and we close an unrelated
fd.

This race has not been observed anywhere as far as we are aware.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
tools/libxl/libxl_fork.c